package com.rock.upms.client.controller;

import javax.servlet.http.HttpServletRequest;
import org.apache.shiro.SecurityUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * 退出系统控制类Created by hotdog on 2018/1/10.
 */
@Controller
@Api(value = "登录验证", description = "登录验证")
public class LogoutController {

	@ApiOperation(value = "退出登录")
	@RequestMapping(value = "${adminPath}/logout", method = RequestMethod.GET)
	public String logout(HttpServletRequest request) {
		// shiro退出登录
		SecurityUtils.getSubject().logout();
		// 跳回原地址
		String redirectUrl = request.getHeader("Referer");
		if (null == redirectUrl) {
			redirectUrl = "/";
		}
		return "redirect:" + redirectUrl;
	}
}
